/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.pro.entity;

import org.hibernate.validator.constraints.Length;
import com.thinkgem.jeesite.modules.sys.entity.User;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.thinkgem.jeesite.common.persistence.DataEntity;
import com.thinkgem.jeesite.common.utils.TimeUtil;
import com.thinkgem.jeesite.common.utils.excel.annotation.ExcelField;
import com.thinkgem.jeesite.common.utils.excel.fieldtype.UserType;

/**
 * 任务管理Entity
 * @author fanqinglong
 * @version 2017-04-25
 */
public class ProjectTask extends DataEntity<ProjectTask> {
	
	private static final long serialVersionUID = 1L;
	private String name;		// 任务名称
	private TaskGroup taskGroup;		// 所属任务组id
	private Project project;		// 所属项目id
	private User manager;		// 负责人id
	private String priority;		// 优先级
	private Date startTime;		// 开始时间
	private Date endTime;		// 结束时间
	private String status;		// 任务状态
	private Date updateTime;		// update_time
	private String uploadDocument;   //上传文档
	private Long remaingDays;     // 剩余天数
	private String flag;     //  因为框架中的delFlag被设置为JSON忽略，所以重新声明一个字段，用以记录delFlag的值，
							//  用于甘特图中根据是否归档状态来判断是否可以被
	private String groupName;   //导入时的任务组名称
	private String failReason;   //导入时校验失败的原因,1:时间校验失败,2:excel里重名,3:已有该条记录,4:负责人不存在 ,5:优先级写入错误
	
	public ProjectTask() {
		super();
	}

	public ProjectTask(String id){
		super(id);
	}

	@Length(min=0, max=64, message="任务名称长度必须介于 0 和 64 之间")
	@ExcelField(title = "任务名称",align=2,sort=10)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public TaskGroup getTaskGroup() {
		return taskGroup;
	}

	public void setTaskGroup(TaskGroup taskGroup) {
		this.taskGroup = taskGroup;
	}

	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	@ExcelField(title = "负责人",align=2,sort=30,fieldType=UserType.class)
	public User getManager() {
		return manager;
	}

	public void setManager(User manager) {
		this.manager = manager;
	}
	
	@Length(min=0, max=2, message="优先级长度必须介于 0 和 2 之间")
	@ExcelField(title = "优先级",align=2,sort=40,dictType="task_priority")
	public String getPriority() {
		return priority;
	}

	public void setPriority(String priority) {
		this.priority = priority;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title = "开始时间",align=2,sort=50)
	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title = "结束时间",align=2,sort=60)
	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	
	@Length(min=0, max=2, message="任务状态长度必须介于 0 和 2 之间")
	@ExcelField(title = "任务状态",align=2,sort=70,dictType="task_status")
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public String getUploadDocument() {
		return uploadDocument;
	}

	public void setUploadDocument(String uploadDocument) {
		this.uploadDocument = uploadDocument;
	}

	public Long getRemaingDays() {
		return null != endTime?TimeUtil.countDays(endTime,new Date()):0;
	}

	public void setRemaingDays(Long remaingDays) {
		this.remaingDays = remaingDays;
	}

	public String getFlag() {
		return this.delFlag;
	}

	public void setFlag(String flag) {
		this.flag = flag;
	}

	@JsonIgnore
	@ExcelField(title = "所属任务组",align=2,sort=20)
	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	public String getFailReason() {
		return failReason;
	}

	public void setFailReason(String failReason) {
		this.failReason = failReason;
	}
}